//
//  YCLifeServiceDetailViewController.m
//  YCSchool
//
//  Created by gmall on 16/5/6.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  生活服务详情

#import "YCLifeServiceDetailViewController.h"
#import "PreviewPhotoViewController.h"

@interface YCLifeServiceDetailViewController ()<SDCycleScrollViewDelegate>
/** 轮播  */
@property (nonatomic, weak) SDCycleScrollView *cycleScrollView;
/** 介绍  */
@property (nonatomic, weak) UILabel *introductionLabel;
/** 地址  */
@property (nonatomic, weak) UILabel *addresslabel;
@end

@implementation YCLifeServiceDetailViewController

- (instancetype)initWithTitleName:(NSString *)titleName
{
    if (self = [super init]) {
        self.navigationItem.title = titleName;
    }
    return self;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self yc_addBackBarButtonItem];
    [self makeView];

}
- (void)makeView
{
    
    SDCycleScrollView *cycleScrollView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectMake(0, 0, kScreenWidth, 202) delegate:self placeholderImage:[UIImage yc_placeHolderImageForSize:CGSizeMake(kScreenWidth, 202)]];
    cycleScrollView.imageURLStringsGroup = @[@"http://img1.3lian.com/2015/w7/98/d/22.jpg",
                                             @"http://img1.3lian.com/2015/w7/90/d/5.jpg",
                                             @"http://img1.3lian.com/2015/w7/90/d/1.jpg",
                                             @"http://pic37.nipic.com/20140209/8821914_163234218136_2.jpg",
                                             @"http://pic39.nipic.com/20140226/18071023_162553457000_2.jpg",
                                             @"http://imgsrc.baidu.com/forum/pic/item/645b8701a18b87d6e716e197070828381e30fdae.jpg"];//网络图片链接数组
    cycleScrollView.delegate = self;
    cycleScrollView.pageControlAliment = SDCycleScrollViewPageContolAlimentCenter;
    cycleScrollView.pageDotColor = [UIColor yc_colorWithUInt:0xffffff alpha:0.5];
    cycleScrollView.currentPageDotColor = [UIColor yc_colorWithUInt:0xffffff];
    cycleScrollView.pageControlDotSize = CGSizeMake(12, 12);
    cycleScrollView.hidesForSinglePage = YES;
    cycleScrollView.autoScrollTimeInterval = 2.0;//2s自动轮播
    
    [self.view addSubview:cycleScrollView];
    self.cycleScrollView = cycleScrollView;
    
    
    UILabel *introductionLabel = [[UILabel alloc] init];
    introductionLabel.font = [UIFont systemFontOfSize:13];
    introductionLabel.numberOfLines = 0;
    introductionLabel.textColor = [UIColor yc_colorWithUInt:0x333333];
    introductionLabel.text = @"学员除了可以在食堂就餐个,学校还提供必来客,优格冷饮等多样选择,西式快餐(如汉堡.炸鸡.薯条等),中式快餐及小吃(如盖饭.炸洋芋.小锅米线等),以及各类冷饮满足学员的不同需求.";
    [self.view addSubview:introductionLabel];
    self.introductionLabel = introductionLabel;
    
    // 价格
    UILabel *addresslabel = [[UILabel alloc] init];
    addresslabel.font = [UIFont systemFontOfSize:13];
    addresslabel.numberOfLines = 0;
    addresslabel.textColor = [UIColor yc_colorWithUInt:0x333333];
    addresslabel.text = @"地址:综合楼附一楼,停车场旁边.";
    [self.view addSubview:addresslabel];
    self.addresslabel = addresslabel;
    
    [cycleScrollView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.equalTo(self.view).offset(30);
        make.right.equalTo(self.view).offset(-30);
        make.height.equalTo(cycleScrollView.mas_width);
    }];
    
    [introductionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(cycleScrollView.mas_bottom).offset(20);
        make.left.right.equalTo(cycleScrollView);
    }];
    
    [addresslabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(introductionLabel);
        make.top.equalTo(introductionLabel.mas_bottom).offset(15);
    }];
    
}

#pragma mark - <SDCycleScrollViewDelegate>
/** 点击图片回调 */
- (void)cycleScrollView:(SDCycleScrollView *)cycleScrollView didSelectItemAtIndex:(NSInteger)index
{
    NSMutableArray *imagesArray = (NSMutableArray *)cycleScrollView.imageURLStringsGroup;
    //预览图片
    PreviewPhotoViewController *vc = [[PreviewPhotoViewController alloc] initWithImages:imagesArray displayIndex:index rightBarButtonItemTitle:@"" clickBlock:^(PreviewPhotoViewController *viewController, NSMutableArray *images, NSUInteger currentIndex) {
        YCLog(@"%@，%zd",images,currentIndex);
    }];
    [self.navigationController pushViewController:vc animated:YES];
}


@end
